package ucd.smarthome.security.securityinterface;

import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Properties;

import ucd.smarthome.databaseinterface.User;
import ucd.smarthome.datastore.DatabaseImpl;
import ucd.smarthome.security.securityimpl.SecurityInterface;

public class SecurityImpl implements SecurityInterface {
	
	
	private DatabaseImpl db;
	
	
	SecurityImpl(DatabaseImpl db){
		this.db=db;
	}
	
	@Override
	public int login(String username, String password) {
		User user;
		try {
			user = this.db.checkUser(username, password);
			return user.getPriority();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			if(e.getMessage()=="Password not meet"){
				return -1;
			}
			else if(e.getMessage()=="No User Exists"){
				
			}
			return -1;
		}


	}

	@Override
	public boolean logout(String username) {
		return false;
	}
	
	

	
	

}
